﻿using EntityModels.Entities;
using Microsoft.EntityFrameworkCore;


namespace EntityModels.DbContexts
{
    /// <summary>
    /// 自定义数据库函数和映射
    /// </summary>
    public class TableValueFunctionDbContext : DbContext
    {
        public IQueryable<FunTableEntity> GetFunTable(int number) => FromExpression(() => GetFunTable(number));

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<FunTableEntity>().HasNoKey();

            modelBuilder.HasDbFunction(() => GetFunTable(default))
                .HasName("FunTable");
        }
    }
}
